﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using proRFID_DiemDanh.Chung;

namespace proRFID_DiemDanh.Khoa
{
    public partial class ThemKhoa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                txt_TenKhoa.Focus();
        }

        protected void Imgcmd_ThemKhoa_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt= new DataTable();
            dt=mdKhoa.sp_Khoa_Insert(txt_TenKhoa.Text);
            if (dt.Rows[0]["ErrCode"].ToString() == "0")
            {
                mdMain.OKCancelBox(this, dt.Rows[0]["ErrMsg"].ToString() + "\\nBạn có muốn thêm dữ liệu nữa không?", "/Khoa/Khoa.aspx");
                txt_TenKhoa.Text = "";
                txt_TenKhoa.Focus();
            }
            else if (dt.Rows[0]["ErrCode"].ToString() == "1")
                mdMain.OKBox(this, dt.Rows[0]["ErrMsg"].ToString(), "/Khoa/Khoa.aspx");
            else
            {
                mdMain.OKCancelBox(this, dt.Rows[0]["ErrMsg"].ToString(), "/Khoa/Khoa.aspx");
                txt_TenKhoa.Focus();
            }
        }
    }
}